package mortal.game.control
{
    import Framework.MQ.*;
    import Message.Command.*;
    import Message.Game.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.mvc.core.*;

    public class GainAwardController extends Controller
    {

        public function GainAwardController()
        {
            
        }

        override protected function initServer() : void
        {
            Dispatcher.addEventListener(EventName.GainOnlineAward, this.gainOnlineAwardHandler);
            NetDispatcher.addCmdListener(EGateCommand._ECmdGateOnlineReward, this.onOnlineAwardHandler);
            
        }

        private function onOnlineAwardHandler(param1:MessageBlock) : void
        {
            var _loc_2:* = param1.messageBase as SOnlineRewardMsg;
            var _loc_3:* = new Object();
            _loc_3.time = _loc_2.condition;
            _loc_3.reward = _loc_2.rewardItems;
            _loc_3.type = _loc_2.type;
            if (_loc_2.type == EOnlineReward._EOnlineRewardNewPlayerReward)
            {
                NetDispatcher.dispatchCmd(ServerCommand.NewPlayerAward, _loc_3);
            }
            else if (_loc_2.type == EOnlineReward._EOnlineRewardDailyReward)
            {
                NetDispatcher.dispatchCmd(ServerCommand.DailyAward, _loc_3);
            }
            else if (_loc_2.type == EOnlineReward._EOnlineRewardLevelReward1)
            {
                NetDispatcher.dispatchCmd(ServerCommand.LevelAward, _loc_3);
            }
            
        }

        private function gainOnlineAwardHandler(event:DataEvent) : void
        {
            GameProxy.onlineAwardProxy.gainOnlineAward(event.data as int);
            
        }

    }
}
